$(document).ready(function(){
  $(".showInsertDrug").click(function(){
    $("#insertDrug").removeClass("disable");
  });
  
  $(".disableInsertDrug").click(function(){
    $("#insertDrug").addClass("disable");
  });

  $("#codeDrug").focusout(function () {

      var nameVar = $("#codeDrug").val();
      $.ajax({
          type: "POST",                
          url: "Drug/CheckCodeOfDrug",
          contentType: 'application/json; charset=utf-8',
          data: JSON.stringify({ code: nameVar}),
          async: true,
          processData: false,
          cache: false,
      success: function (data) 
      {
          if (data.Status == "Error")
          {
              $("#throwError2").hide();   
          }
          else 
          {
              $("#throwError2").show();
              $("#codeDrug").select();

          }
      },                
      error: function(exp)        
      {
          //alert('Error address : ' + exp.responseText);
      }                
  }); //end ajax call
  });


  $("#nameDrug").focusout(function () {

      var nameVar = $("#nameDrug").val();
      $.ajax({
          type: "POST",
          url: "Drug/CheckNameOfDrug",
          contentType: 'application/json; charset=utf-8',
          data: JSON.stringify({ name: nameVar }),
          async: true,
          processData: false,
          cache: false,
          success: function (data) {
              if (data.Status == "Error") {
                  $("#throwError1").hide();
              }
              else {
                  $("#throwError1").show();
                  $("#nameDrug").select();

              }
          },
          error: function (exp) {
              //alert('Error address : ' + exp.responseText);
          }
      }); //end ajax call
  });

  //$("#searchDrug").click(function () {

  //    var keySearch = $("#KeySearch").val();
  //    $('#listDrugPaging').fadeOut('normal');
  //    $.ajax({
  //        type: "GET",
  //        url: "Drug/PagingDrug",
  //        contentType: 'application/json; charset=utf-8',
  //        data: JSON.stringify({ KeySearch: keySearch, PageSize: 15, page:1 }),
  //        async: true,
  //        processData: false,
  //        cache: false,
  //        success: function (data) {
  //        },
  //        error: function (exp) {
  //            //alert('Error address : ' + exp.responseText);
  //        }
  //    }); //end ajax call
  //});





});
